<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style:none;
      border: 0 none;
      outline: none;
      text-decoration: none;
    }
    .search{
      height: 40px;
      width:300px;
      border:1px solid #ccc;
      margin: 50px auto;
    }
    .search input:nth-child(1){
      width: 250px;
      height: 40px;
      /* background-color: aqua; */
      padding-left: 10px;
      box-sizing:border-box;
      float: left;
    }
    .search input:nth-child(2){
      width: 50px;
      height: 40px;
      float:left;
    }
    .list{
      width: 250px;
      border: 1px solid #ccc;
      border-top:0px;
      box-shadow: 0px 0px 5px #ddd;
      padding-left: 10px;
      box-sizing: border-box;
      float: left;
      display: none;
    }
   .list li{
      height: 30px;
      line-height: 30px;
    }
    .list a{
      color:#999;
    }
  </style>
</head>
<body>
  
  <div class="search">
    <input type="text" placeholder="请输入关键字">
    <input type="button" value="搜索">
    <div class="list">
      <ul>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
        <li><a href="javascript:;">礼品礼物</a></li>
      </ul>
    </div>
  </div>
 <script>
   var input = document.querySelector('.search input:nth-child(1)')
   var list = document.querySelector('.list')
   console.log(list)
   input.onfocus = function(){
    this.placeholder = '';
    list.style.display = 'block';
    
   }
   input.onblur = function(){
    
    list.style.display = 'none';
    this.placeholder = '请输入关键字';
   }
 </script>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      text-decoration: none;
      list-style: none;
      outline-style: none;
      border: none;
    }
    .search{
      width: 300px;
      height: 40px;
      border: 1px solid #ccc;
      margin: 40px auto;
      /* line-height: 40px; */
    }
    input[type='text']{
      width: 250px;
      height: 40px;
      box-sizing: border-box;
      padding-left: 10px;
      float: left;
      color:#ccc
    }
    .search input:nth-child(2){
      width: 50px;
      height: 40px;
      box-sizing: border-box;
      float:left;
    }
    .list{
      width: 250px;
      border: 1px solid #ccc;
      box-shadow:0px 0px 5px #ddd;
      float:left;
      padding-left: 10px;
      box-sizing: border-box;
      border-top:none;
      display: none;
    }
    li{
      height: 30px;
      line-height: 30px;
    }
    .list a{
      color:#999;
    }
  </style>
</head>
<body>
  <div class="search">
    <input type="text" value="请输入关键字">
    <input type="button" value="按钮">
    <div class="list">
      <ul>
        <li><a href="javastript:;">中秋礼品</a></li>
        <li><a href="javastript:;">中秋礼品</a></li>
        <li><a href="javastript:;">中秋礼品</a></li>
        <li><a href="javastript:;">中秋礼品</a></li>
        <li><a href="javastript:;">中秋礼品</a></li>
        <li><a href="javastript:;">中秋礼品</a></li>
        <li><a href="javastript:;">中秋礼品</a></li>
      </ul>
    </div>
  </div>
  <script>
    var input = document.querySelector('.search input[type="text"]');
    var list = document.querySelector('.list');
    var lis = document.querySelectorAll('li');
    console.log(list)
    input.onfocus = function(){
      list.style.display = "block";
      this.value = '';
    } 
    input.onblur = function(){
      list.style.display = 'none';
      this.value = "请输入关键字"
    }
    for(var i = 0; i < lis.length; i++){
      lis[i].onmouseenter = function(){
        this.style.backgroundColor = '#ccc';
      }
      lis[i].onmouseleave = function(){
        this.style.backgroundColor = '';
      }
    }
  </script>
</body>
</html> -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
      outline-style: none;
      text-decoration: none;
      border: none;
    }
    .search{
      width: 300px;
      height: 40px;
      margin: 40px auto;
      border:1px solid #ccc;
    }
    input:nth-child(1){
      width: 250px;
      height: 40px;
      float:left;
      padding-left: 10px;
      box-sizing: border-box;
    }
    input[type="button"]{
      width: 50px;
      height: 40px;
    }
    .list{
      width: 250px;
      border: 1px solid #ccc;
      box-shadow: 0px 0px 5px #ddd;
      border-top:none;
      padding-left: 10px;
      box-sizing: border-box;
      display:none;
    }
    li{
      height: 30px;
      line-height: 30px;
    }
    a{
      color:#999;
    }
  </style>
</head>
<body>
  <div class="search">
    <input type="text" placeholder="请输入关键字">
    <input type="button" value="按钮">
    <div class="list">
      <ul>
        <li><a href="javastipt:;">中秋礼品</a></li>
        <li><a href="javastipt:;">中秋礼品</a></li>
        <li><a href="javastipt:;">中秋礼品</a></li>
        <li><a href="javastipt:;">中秋礼品</a></li>
        <li><a href="javastipt:;">中秋礼品</a></li>
        <li><a href="javastipt:;">中秋礼品</a></li>
        <li><a href="javastipt:;">中秋礼品</a></li>
      </ul>
    </div>
  </div>
  <script>
    var input = document.querySelector('input:nth-child(1)');
    var list = document.querySelector('.list');
    // var lis = document.querySelectorAll('li');
    var a = document.querySelectorAll('a')
    input.onfocus = function(){
      list.style.display = 'block';
      this.placeholder = '';
    }
    input.onblur = function(){
      list.style.display = 'none';
      this.placeholder = '请输入关键字';
    }
    
    for(var j = 0; j < a.length; j++){
      a[j].onmouseenter = function(){
        this.style.color = 'red';
      }
      a[j].onmouseleave = function(){
        this.style.color = '#999'
      }
    }
  </script>
</body>
</html>